package cn.aitrox.ry.service.anno.dao.impl;

import cn.aitrox.ry.common.dao.MapperSqlCallback;
import cn.aitrox.ry.common.dao.impl.BaseDaoImpl;
import cn.aitrox.ry.service.anno.dao.AnnoLesionToolDao;
import cn.aitrox.ry.service.anno.entity.AnnoLesionToolEntity;
import cn.aitrox.ry.service.anno.mapper.AnnoLesionToolMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class AnnoLesionToolDaoImpl extends BaseDaoImpl<AnnoLesionToolEntity> implements AnnoLesionToolDao {

    @Autowired
    private AnnoLesionToolMapper mapper;

    @Override
    public List<AnnoLesionToolEntity> findByTaskId(Integer taskId) {

        AnnoLesionToolEntity cond = new AnnoLesionToolEntity();
        cond.setTaskId(taskId);

        return findByCondition(cond, null);
    }

    @Override
    public void batchSave(List<AnnoLesionToolEntity> list) {
        batchInsert(list, 1000, new MapperSqlCallback<AnnoLesionToolEntity>() {
            @Override
            public void batchInsert(List<AnnoLesionToolEntity> objList) {
                mapper.batchInsert(objList);
            }
        });
    }

    @Override
    public void deleteByTaskId(Integer taskId) {
        mapper.deleteByTaskId(taskId);
    }

    @Override
    public AnnoLesionToolEntity findByTaskIdLesionTool(Integer taskId, String lesion, String tool) {
        AnnoLesionToolEntity cond = new AnnoLesionToolEntity(null, taskId, lesion, tool, null, null);
        return super.findOne(cond);
    }
}
